package com.xtm.exercise.factory;

import com.xtm.exercise.service.Car;
import com.xtm.exercise.service.impl.Audi;
import com.xtm.exercise.service.impl.BMW;

/***
 *@Author: 王磊
 *@CreateTime: 2025-06-12  21:20
 *@Description: 定义一个工厂类，用于创建产品对象
 *@title: CarFactory
 */
public class CarFactory {

    public static Car create(String carName) {

        switch (carName) {
            case "奥迪":
                return new Audi();
            case "宝马":
                return new BMW();
            default:
                throw new IllegalArgumentException("Invalid carName: " + carName);

        }

    }
}
